<?php

class UMessage {
	var $datasetId;
	var $lang;
	var $message;
	var $title;
	var $author;
	
	function insertChinese(&$db, $datasetId, $lang, $message, $title, $author) {
		$msg = sqlEscape($message);
		$ti = sqlEscape($title);
		$au = sqlEscape($author);
		$sql = "INSERT INTO key_message 
			(datasetId, language, message, title, author) 
		VALUES('$datasetId', '$lang', '$msg', '$ti', '$au')";  
		
		$db->doInsert($sql);
	}	
	
	function findByDatasetId(&$db, $datasetId, $lang) {
		$sql = "SELECT * from key_message 
		where datasetId = '$datasetId' and language = '$lang'";
		$user =& $db->selectOne($sql, new UMessage());
		return $user;
	}
	
	function updateChinese(&$db, $datasetId, $lang, $message, $title, $author) {
		$msg = sqlEscape($message);
		$ti = sqlEscape($title);
		$au = sqlEscape($author);
		$sql = "UPDATE key_message set message = '$msg',
		title = '$ti',
		author = '$au'
		where datasetId ='$datasetId' and language = '$lang'";
		$db->doQuery($sql);
	}		
	
	function dbLoadCallback(&$dbRow) {
		if ( !$dbRow ) {
			return;
		}
		if ( isset($dbRow['datasetId']) ) {		
			$this->datasetId = $dbRow['datasetId'];
		}	
		if ( isset($dbRow['language']) ) {
			$this->lang = $dbRow['language'];
		} else {
			$this->lang = '';
		}
		if ( isset($dbRow['message']) ) {
			$this->message = $dbRow['message'];
		} else {
			$this->message = '';
		}
		if ( isset($dbRow['title']) ) {
			$this->title = $dbRow['title'];
		} else {
			$this->title = '';
		}
		if ( isset($dbRow['author']) ) {
			$this->author = $dbRow['author'];
		} else {
			$this->author = '';
		}
	}	
	
	function &newInstance() {
		$inst = new UMessage();
		return $inst;
	}
}

?>